#include "laser.h"

static LaserInstance *laser_instance = NULL; // 可以由app保存此指针

static void LaserRxCallback()
{
    static uint8_t *rxbuff;
    static Laser_Measure_s *measure;
    rxbuff = laser_instance->laser_usart_instance->recv_buff;
    measure = &laser_instance->laser_measure;
    measure->laser_distance = (float)strtod(rxbuff, NULL);
    // ...
}

/*测距仪初始化*/
LaserInstance *LaserInit(Laser_Init_Config_s *laser_config)
{
    laser_instance = (LaserInstance *)malloc(sizeof(LaserInstance));
    memset(laser_instance, 0, sizeof(LaserInstance));

    laser_config->usart_config.module_callback = LaserRxCallback;
    laser_instance->laser_usart_instance = USARTRegister(&laser_config);

    return laser_instance;
}
